package seiacpsjava.sortalgorithms;

import static org.junit.Assert.*;

import org.junit.Test;

public class BubbleSortTestCase {

	@Test
	public void testSortWithEmptyArray() {
		
		int [] items = {};
		
		SortAlgorithm algorithm = SortAlgorithmFactory.getBubbleSortAlgorithm();
		
		algorithm.sort(items);
		
		assertEquals(items.length, 0);
		
	}
	
	
	@Test
	public void testSortwithOneItem() {
		
		int [] items = {5};
		
		SortAlgorithm algorithm = SortAlgorithmFactory.getBubbleSortAlgorithm();
		
		algorithm.sort(items);
		
		
		assertEquals(items[0], 5);
		
	}
	
	@Test
	public void testSortwithTwoItems() {
		
		int [] items = {5,1};
		
		SortAlgorithm algorithm = SortAlgorithmFactory.getBubbleSortAlgorithm();
		
		algorithm.sort(items);
		
		
		assertEquals(items[0], 1);
		assertEquals(items[1], 5);
		
	}
	
	
	@Test
	public void testSort() {
		
		int [] items = { 5, 1, 4, 2, 8};
		
		SortAlgorithm algorithm = SortAlgorithmFactory.getBubbleSortAlgorithm();
		
		algorithm.sort(items);
		
		assertEquals(items[0], 1);
		assertEquals(items[1], 2);
		assertEquals(items[2], 4);
		assertEquals(items[3], 5);
		assertEquals(items[4], 8);
	}
	
}
